package com.smart.web.controller.system;


import com.smart.common.core.domain.MobileResult;
import com.smart.common.core.domain.R;
import com.smart.common.core.domain.VehicleTripInfo;
import com.smart.system.service.IMobileUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/system/mobile")
@Api(tags = "车载设备")
public class MobileUtilController {
    @Autowired
    private IMobileUnitService mobileUnitService;

    /**
     * 获取session
     */
    @ApiOperation(value = "获取session")
    @GetMapping("/getSession")
    public R<MobileResult> getSession() {
        return R.ok(mobileUnitService.getSession());
    }

    /**
     * 获取视频路径
     */
    @ApiOperation(value = "获取视频路径")
    @GetMapping("/getVideoUrl")
    public R<String> getVideoUrl(String carNumber) {
        return R.ok(mobileUnitService.getVideoUrl(carNumber));
    }

    /**
     * 获取车辆位置
     */
    @ApiOperation(value = "获取车辆位置")
    @GetMapping("/getLocation")
    public R<Object> getLocation(String carNumber) {
        return R.ok(mobileUnitService.getLocation(carNumber));
    }

    /**
     * 获取车辆里程报表
     */
    @ApiOperation(value = "获取车辆里程报表")
    @GetMapping("/getMileageStatement")
    public R<List<VehicleTripInfo>> getMileageStatement(String[] carNumbers, String startTime, String endTime) {
        return R.ok(mobileUnitService.getMileageStatement(Arrays.asList(carNumbers), startTime, endTime));
    }

    /**
     * 获取当前车辆详情
     */
    @ApiOperation(value = "获取当前车辆详情")
    @GetMapping("/getCarInfoDetails")
    public R<Object> getCarInfoDetails(String[] carNumbers) {
        return R.ok(mobileUnitService.getCarInfoDetails(Arrays.asList(carNumbers)));
    }
}
